/**
 * Created by Administrator on 2018/7/13.
 */

$(function () {
    $('.go_btn').on('click', function () {
        $(this).addClass('go_active');
        $('.prize').slideDown(300)
    })
    $('#ties').on('click',function () {
        $('.usermask').show();
    })
    $('.usermask').on('click', '.close', function () {
        $('.usermask').hide();
    })
    $('.alertint').on('click', '.close', function () {
        $('.alertint').hide();
    })
    var reg = {
        tel: /^1[34578]\d{9}$/
    };
    $('#subtim').on('click', function () {
        var user = $.trim($('#user').val());
        var phone = $.trim($('#phone').val());
        var address = $.trim($('#address').val());
        if (!user) {
            layer.open({
                content: '请输入用户名!',
                skin: 'msg',
                time: 2 //停留2秒
            });
            $('#user').focus();
            return false;
        }
        if (!phone) {
            layer.open({
                content: '请输入手机号码!',
                skin: 'msg',
                time: 2
            });
            $('#phone').focus();
            return false;
        }else {
            var regs = reg["tel"];
            var r = phone.match(regs);
            if (r == null) {
                layer.open({
                    content: '你输入的手机格式不正确!',
                    skin: 'msg',
                    time: 2
                })
                $('#phone').focus();
                return false;
            }
        }
        if (!address) {
            layer.open({
                content: '请输入收货地址!',
                skin: 'msg',
                time: 2
            });
            $('#address').focus();
            return false;
        }
    });
})